package team.seekers.oj.group.converter;
import team.seekers.oj.group.dto.GroupCreateReqDTO;
import team.seekers.oj.group.entity.dao.GroupDO;

import java.util.List;
import java.util.Optional;

@org.mapstruct.Mapper(
        componentModel = "spring",
        imports = {Optional.class, List.class}
)
public interface GroupCreateReqConverter extends BaseGroupConverter<GroupDO, GroupCreateReqDTO> {

    @org.mapstruct.Mapping(
            target = "userNum",
            expression = "java( Optional.ofNullable(source.getUsers()).map(List::size).orElse(0) )"
    )
    GroupDO from(GroupCreateReqDTO source);


}